/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ecouteurs;

import controleur.Controleur;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JCheckBox;
import javax.swing.JOptionPane;
import javax.swing.JSlider;
import javax.swing.JTextField;

/**
 *
 * @author Baptiste
 */

public class EcouteurReinit implements MouseListener{
 
    private JTextField txtAgents;
    private JTextField txtRessources;
    private JCheckBox prise;
    private JTextField txtStep;
    private JSlider delai;
    private JCheckBox ephemeres;
    private JCheckBox champAttractif;
    private JCheckBox enablePheromones;
    private JCheckBox pheroEphemeres;
    private JTextField lifePhero;
    private JCheckBox pheroAttractives;
    
    public EcouteurReinit(JTextField txtAgents, JTextField txtRessources,
                          JCheckBox prise, JTextField txtStep, JSlider delai, JCheckBox ephemeres,
                          JCheckBox champAttractif, JCheckBox enablePheromones, JCheckBox pheroEphemeres,
                          JTextField lifePhero, JCheckBox pheroAttractives) {
        this.txtAgents = txtAgents;
        this.txtRessources = txtRessources;
        this.prise = prise;
        this.txtStep = txtStep;
        this.delai = delai;
        this.ephemeres = ephemeres;
        this.champAttractif = champAttractif;
        this.enablePheromones = enablePheromones;
        this.pheroEphemeres = pheroEphemeres;
        this.lifePhero = lifePhero;
        this.pheroAttractives = pheroAttractives;
    }

    public void mouseClicked(MouseEvent e) {
        // Réinitialisation
        try{
        new Thread(Controleur.getInstance(true, Integer.parseInt(txtAgents.getText()),
                                                Integer.parseInt(txtRessources.getText()),
                                                prise.isSelected(),
                                                Integer.parseInt(txtStep.getText()),
                                                delai.getValue(),
                                                ephemeres.isSelected(),
                                                champAttractif.isSelected(),
                                                enablePheromones.isSelected(),
                                                pheroEphemeres.isSelected(),
                                                Integer.parseInt(lifePhero.getText()),
                                                pheroAttractives.isSelected()));
        }
        catch(java.lang.NumberFormatException ne){
            JOptionPane.showMessageDialog(null, "Veuillez remplir convenablement les champs...", "Erreur evitee.. qui aurait pu être grave", JOptionPane.ERROR_MESSAGE);

        }
    }

    public void mousePressed(MouseEvent e) {
      //   throw new UnsupportedOperationException("Not supported yet.");
      
    }

    public void mouseReleased(MouseEvent e) {
     //   throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseEntered(MouseEvent e) {
    //    throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseExited(MouseEvent e) {
    //    throw new UnsupportedOperationException("Not supported yet.");
    }

}
